package org.uds.android.fitdroid.demo.activity.spatial;

import org.uds.android.fitdroid.demo.apis.R;

import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.View;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;

public class MyMap extends MapActivity {

	public static final String TAG = "MyMap";

	private MapView mapView;
	private MyLocationOverlay myLocationOverlay;

	private MapController mapController;
	private View zoomView;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		getWindow().setFormat(PixelFormat.TRANSPARENT);

		// Inflate our UI from its XML layout description.
		setContentView(R.layout.mapview);

		mapView = (MapView) findViewById(R.id.map);
		mapController = mapView.getController();

		initMap();

		mapController.setZoom(18);
		mapView.setClickable(true);
		mapView.setEnabled(true);
		mapView.setSatellite(true);

		/*
		LinearLayout zoom = (LinearLayout) findViewById(R.id.zoom_holder);
		zoomView = mapView.getZoomControls();
		zoomView.setLayoutParams(new ViewGroup.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT));
		zoom.addView(zoomView);
		*/
		mapView.displayZoomControls(true);
	}

	private void initMap() {
		myLocationOverlay = new MyLocationOverlay(this, mapView);
		mapView.getOverlays().add(myLocationOverlay);
		myLocationOverlay.enableCompass();
		myLocationOverlay.enableMyLocation();
		myLocationOverlay.runOnFirstFix(new Runnable() {
			public void run() {
				mapController.animateTo(myLocationOverlay.getMyLocation());
			}
		});
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}